from flask_admin.form import ImageUploadField

from poker_bot.admin_panel.app.constants import media_path
from poker_bot.admin_panel.app.views import MyBaseModelView


class DepositModelView(MyBaseModelView):
    column_list = (
        "id",
        "status",
        "summ",
        "user",
        "payment_method",
        "account",
        "created_at",
    )

    form_excluded_columns = ("created_at", "updated_at")

    form_extra_fields = {
        "invoice_screenshot_path": ImageUploadField(
            "Скриншот оплаты",
            base_path=media_path,
            allow_overwrite=True,
            allowed_extensions=["png", "jpg"],
            endpoint="media_bp.invoices",
        )
    }

    column_filters = ("summ", "status", "account")

    column_labels = {
        "status": "Статус",
        "summ": "Сумма",
        "payment_method": "Метод оплаты",
        "invoice_screenshot_path": "Скриншот оплаты",
        "user": "Пользователь",
        "account": "На какой аккаунт",
        "created_at": "Дата создания",
    }

    column_default_sort = ("id", True)
